<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output doctype-system="isetup.dtd" indent="yes" encoding="utf-8"/>

<xsl:strip-space elements="*"/>

<xsl:template match="yasyx">

  <xsl:comment>
    Inno Setup Preprocessor Reference
    Copyright (C) 1997-2020 Jordan Russell
    Portions Copyright (C) 2000-2020 Martijn Laan
    For conditions of distribution and use, see LICENSE.TXT.
    Portions Copyright (C) 2001-2004 Alex Yackimoff

    This file is automatically generated. Do not edit.
  </xsl:comment>

  <ishelp version="1">

  <xsl:comment>Table of contents</xsl:comment>

  <contents>
    <contentsheading title="Inno Setup Preprocessor">
      <contentstopic title="Introduction" topic="isppoverview" />
      <contentstopic title="Directives Reference" topic="directives" />
      <contentstopic title="Support Functions Reference" topic="funcs" />
      <contentstopic title="User Defined Functions" topic="macros" />
      <contentstopic title="Expression Syntax" topic="expressions" />
      <contentstopic title="Predefined Variables" topic="predefinedvars" />
      <contentstopic title="Line Spanning" topic="linespan" />
      <contentsheading title="Other Information">
        <contentstopic title="Visibility of Identifiers" topic="visibility" />
        <contentstopic title="Example Script" topic="example" />
        <contentstopic title="ISPPBuiltins.iss" topic="builtinsiss" />
        <contentstopic title="Extended Command Line Compiler" topic="isppcc" />
      </contentsheading>
    </contentsheading>
  </contents>

  <xsl:comment>Topics</xsl:comment>

  <xsl:apply-templates/>

  </ishelp>

</xsl:template>

<xsl:variable name="lcletters">abcdefghijklmnopqrstuvwxyz</xsl:variable>
<xsl:variable name="ucletters">ABCDEFGHIJKLMNOPQRSTUVWXYZ</xsl:variable>

<xsl:template match="topic">
  <topic name="{translate(@id,$ucletters,$lcletters)}" title="Inno Setup Preprocessor: {title}">
  <xsl:if test="title">
    <keyword value="{title}" />
  </xsl:if>
  <xsl:for-each select="keywords/kwd">
    <keyword value="{text()}" />
  </xsl:for-each>
  <body>
    <xsl:apply-templates select="*[name()!='topic']"/>
    <xsl:if test="topic">
      <heading><xsl:value-of select="subtopicstitle"/></heading>
      <ul>
        <xsl:for-each select="topic">
          <xsl:if test="title">
          <li><link topic="{translate(@id,$ucletters,$lcletters)}"><xsl:value-of select="title"/></link></li>
          </xsl:if>
        </xsl:for-each>
      </ul>
    </xsl:if>
  </body>
  </topic>
  <xsl:for-each select="topic">
    <xsl:apply-templates select="."/>
  </xsl:for-each>
</xsl:template>

<xsl:template match="title">
</xsl:template>

<xsl:template match="subtopicstitle">
</xsl:template>

<xsl:template match="line">
  <xsl:apply-templates/><br />
</xsl:template>

<xsl:template match="table">
  <table><xsl:apply-templates/></table>
</xsl:template>

<xsl:template match="tr">
  <tr><xsl:apply-templates/></tr>
</xsl:template>

<xsl:template match="td">
  <td><xsl:apply-templates/></td>
</xsl:template>

<xsl:template match="code">
  <tt><xsl:apply-templates/></tt>
</xsl:template>

<xsl:template match="keywords">
</xsl:template>

<xsl:template match="description">
  <xsl:if test="@header='yes'">
  <heading>Description</heading>
  </xsl:if>
  <xsl:apply-templates/>
</xsl:template>

<xsl:template match="section">
  <heading><xsl:value-of select="@title"/></heading>
  <xsl:apply-templates/>
</xsl:template>

<xsl:template match="para">
  <p><xsl:apply-templates/></p>
</xsl:template>

<xsl:template match="ul">
  <ul><xsl:apply-templates/></ul>
</xsl:template>

<xsl:template match="li">
  <li><xsl:apply-templates/></li>
</xsl:template>

<xsl:template match="synel">
  <tt><xsl:apply-templates/></tt>
</xsl:template>

<xsl:template match="syntax">
  <heading>Syntax</heading>
  <xsl:apply-templates select="*[@inline!='yes']"/>
</xsl:template>

<xsl:template match="pre">
  <p><tt><xsl:apply-templates/></tt></p>
</xsl:template>

<xsl:template match="alink">
<!--  <link topic="{@kwd}"><xsl:apply-templates/></link> -->
</xsl:template>

<xsl:template match="extlink">
  <extlink href="{@href}"><xsl:apply-templates/></extlink>
</xsl:template>

<xsl:template match="link">
  <xsl:choose>
    <xsl:when test="ancestor::topic/@id=@href">
        <xsl:choose>
        <xsl:when test="text()">
          <xsl:apply-templates/>
        </xsl:when>
        <xsl:otherwise>
          <xsl:choose>
            <xsl:when test="//topic[@id=current()/@href]/@usetitle='no'">
              <xsl:value-of select="//topic[@id=current()/@href]/@id"/>
            </xsl:when>
            <xsl:otherwise>
              <xsl:value-of select="//topic[@id=current()/@href]/title/text()"/>
            </xsl:otherwise>
          </xsl:choose>
        </xsl:otherwise>
        </xsl:choose>
    </xsl:when>
    <xsl:otherwise>
      <link topic="{translate(@href,$ucletters,$lcletters)}">
        <xsl:choose>
        <xsl:when test="text()">
          <xsl:apply-templates/>
        </xsl:when>
        <xsl:otherwise>
          <xsl:choose>
            <xsl:when test="//topic[@id=current()/@href]/@usetitle='no'">
              <xsl:value-of select="//topic[@id=current()/@href]/@id"/>
            </xsl:when>
            <xsl:otherwise>
              <xsl:value-of select="//topic[@id=current()/@href]/title/text()"/>
            </xsl:otherwise>
          </xsl:choose>
        </xsl:otherwise>
        </xsl:choose>
      </link></xsl:otherwise>
  </xsl:choose>
</xsl:template>

<!--SYNTAX-->

<xsl:template match="txt">
  <xsl:if test="(ancestor::opt or ancestor::group or ancestor::define[@inline='yes'])=0 or position()!=1">
    <xsl:text> </xsl:text>
  </xsl:if>
  <b><xsl:value-of select="text()"/></b>
  <xsl:if test="(ancestor::opt or ancestor::group or ancestor::define[@inline='yes'])=0 or position()!=last()">
    <xsl:text> </xsl:text>
  </xsl:if>
</xsl:template>

<xsl:template match="define/variant">
  <xsl:apply-templates/>
</xsl:template>

<xsl:template match="b">
  <xsl:copy-of select="."/></xsl:template>

<xsl:template match="i">
  <xsl:copy-of select="."/></xsl:template>

<xsl:template match="nt">
  <xsl:if test="(ancestor::opt or ancestor::group)=0 or position()!=last()">
    <xsl:text> </xsl:text>
  </xsl:if>
  <xsl:choose>
    <xsl:when test="@name">
      <xsl:choose>
        <xsl:when test="id(@name)[@inline='yes']">
          <xsl:apply-templates select="id(@name)"/>
        </xsl:when>
        <xsl:otherwise>
          <xsl:text>&lt;</xsl:text>
          <!--link>
            <xsl:attribute name="href">
              <xsl:value-of select="@name"/>
            </xsl:attribute-->
            <xsl:value-of select="@name"/>
          <!--/link-->
          <xsl:text>&gt;</xsl:text>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:when>
    <xsl:otherwise>
      <xsl:text>&lt;</xsl:text>
      <xsl:value-of select="text()"/>
      <xsl:text>&gt;</xsl:text>
    </xsl:otherwise>
  </xsl:choose>
  <xsl:if test="(ancestor::opt or ancestor::group)=0 or position()!=last()">
    <xsl:text> </xsl:text>
  </xsl:if>
</xsl:template>

<xsl:template match="opt">
  <xsl:if test="(ancestor::opt or ancestor::group)=0 or position()!=1">
    <xsl:text> </xsl:text>
  </xsl:if>
  <xsl:text>[</xsl:text>
  <xsl:apply-templates/>
  <xsl:text>]</xsl:text>
  <xsl:if test="@repeated='yes'">
    <xsl:text>...</xsl:text>
  </xsl:if>
  <xsl:if test="(ancestor::opt or ancestor::group)=0 or position()!=last()">
    <xsl:text> </xsl:text>
  </xsl:if>
</xsl:template>

<xsl:template match="define">
  <xsl:choose>
    <xsl:when test="@inline='yes'">
      <xsl:apply-templates/>
    </xsl:when>
    <xsl:otherwise>
      <xsl:choose>
        <xsl:when test="variant">
            <table>
            <tr>
            <td>
            <i><xsl:value-of select="@id"/>
            <xsl:text>:</xsl:text></i></td>
            <td>  
              <xsl:apply-templates select="variant[position()=1]"/>
            </td>
            </tr>
            <xsl:for-each select="variant[position()!=1]">
              <tr>
                <td></td>
                <td><xsl:apply-templates/></td>
              </tr>
            </xsl:for-each>
            </table>
            <!-- NT DESCRIPTION -->
            <xsl:for-each select="description">
              <para><xsl:value-of select="text()"/></para>
            </xsl:for-each>
        </xsl:when>
        <xsl:otherwise>
          <table><tr><td><i><xsl:value-of select="@id"/><xsl:text>:</xsl:text></i>
          </td><td><xsl:apply-templates/></td></tr></table>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

<xsl:template match="br">
  <br/>
</xsl:template>

<xsl:template match="case" name="fromcases">
  <xsl:if test="child::*[position()>1] or id(nt/@name)/@inline='yes'">
    <xsl:text>(</xsl:text>
  </xsl:if>
  <xsl:apply-templates/>
  <xsl:if test="child::*[position()>1] or id(nt/@name)/@inline='yes'">
    <xsl:text>)</xsl:text>
  </xsl:if>
</xsl:template>

<xsl:template match="cases">
  <xsl:for-each select="case[position()!=last()]">
    <xsl:call-template name="fromcases"/>
    <xsl:text> | </xsl:text>
  </xsl:for-each>
  <xsl:apply-templates select="case[position()=last()]"/>
</xsl:template>

<xsl:template match="group">
  <xsl:if test="(ancestor::opt or ancestor::group)=0 or position()!=1">
    <xsl:text> </xsl:text>
  </xsl:if>
  <xsl:text>(</xsl:text>
    <xsl:apply-templates/>
  <xsl:text>)</xsl:text>
  <xsl:if test="@repeated='yes'">
    <xsl:text>...</xsl:text>
  </xsl:if>
  <xsl:if test="(ancestor::opt or ancestor::group)=0 or position()!=last()">
    <xsl:text> </xsl:text>
  </xsl:if>
</xsl:template>

</xsl:stylesheet>